'use strict';

/* Controllers */
app.controller('houseOwnerListCtl', function($scope,$http,rest,$compile,$location,ngDialog,user,$state,$window,uiLoad,$rootScope,$ocLazyLoad) {
    $scope.queryParams = {};
    $scope.checkStatus = {};
    $scope.decorateStatus = {};
    $scope.checkTypeArray = [{ "name": "全部", "value": -1 },
                             { "name": "通电", "value": 0 },
                             { "name": "断电", "value": 1 }];

    $scope.lockTypeArray = [{ "name": "全部", "value": -1 },
                            { "name": "未安装", "value": 0 },
                            { "name": "锁电安装中", "value": 3 },
                            { "name": "锁电安装成功", "value": 4 }];
    var tmpHouseIdArr = "";

    function time(mydate){
      var str = mydate.substring(0,10);
      var dataArr = str.split('-');
      var timeStr = dataArr[0]
        +"年"+dataArr[1]+"月"+dataArr[2]
        +"日";
        return timeStr;
    }

    //监听浏览器大小变化
    // window.onresize = function(){
        // window.location.reload();
        // initDataTables();
    // }
    
    // $scope.$watch('tableChanged',function(){
    //     if ($('.app-aside').width() != 200+"px") {
    //         alert('111111');
    //     }
    // })
    /* 列表按钮的模板，入参：{
        isDisabled: true or false, 按钮是否禁用
        functionName: 按钮ng-click调用函数名
        paramId: ng-click传参，一般为各种id
        buttonText: 按钮文字
    } */
    var btntmp = function (opt) {
        var wrap = document.createElement('div'), abtn = document.createElement('a');
        wrap.appendChild(abtn);
        $(abtn).attr('href', 'javascript:;').addClass('btn new_btn');
        // wrap.appendChild(imgIcon);
        // $(imgIcon).attr('src', 'img/houseIcon.png');
        // $(imgIcon).addClass('houseIcon');
        if (opt.isDisabled) {
            $(abtn).addClass('disabled');
        }
        $(abtn).text(opt.buttonText);
        if (opt.functionName) {
            var ngClick = opt.functionName + '($event, "'+opt.paramId+'")';
            $(abtn).attr('ng-click', ngClick);
        }
        return $(wrap).html();
    }

    var getButtons = function (opt) {

        var getHouseBtn = function (opt) { // 房源恩扭
            if (opt.decorate.checkStatus == 5 || opt.decorate.checkStatus == null) {                           // 装修状态判断
                  return btntmp({
                    isDisabled: false,
                    paramId: opt.houseId,
                    functionName: "updateOrderReturnState",
                    buttonText: "编辑"
                });

            }else{
                return btntmp({
                    isDisabled: false,
                    paramId: opt.houseId,
                    functionName: "viewOrderReturnState",
                    buttonText: "查看详情"
                });
            }
          
        }

        var getContractBtn = function (opt) { // 租客合同创建和编辑按钮

            // opt.contract 参数说明：
            //      opt.contract.contractId     合同ID
            //      opt.contract.openId         盈家账户中心openId
            //      opt.contract.status         状态
            //          0 = 未创建； 1 = 待确认； 2 = 已确认； 3 = 已失效； 4 = 已解约； 5 = 已退租

            if (opt.contract) {
                if (1 == opt.contract.isRefused || 1 == opt.contract.status) {          // 租客未确认合同，可修改
                    return btntmp({                                                       // 或合同被驳回
                        isDisabled: false,
                        paramId: opt.contract.contractId,
                        functionName: "editContractDialog",
                        buttonText: "通电"
                    });
                } else {                                 // 未创建或已失效或已解约或已退租
                    return btntmp({
                        isDisabled: false,
                        paramId: opt.houseId,
                        functionName: "createContractDialog",
                        buttonText: "断电"
                    });
                }
            } else {
                return btntmp({
                    isDisabled: false,
                    paramId: opt.houseId,
                    functionName: "createContractDialog",
                    buttonText: "通电"
                });
            }

        }

        var getDecorateBtn = function (opt) { // 装修贷系列按钮
            if(opt.decorate.checkStatus == 2){
                return btntmp({
                    isDisabled: false,
                    paramId: opt.decorate.decorateId,
                    functionName: "decorateModify",
                    buttonText: "修改装修评估"
                });
            }
            else if(opt.decorate.checkStatus == 0){
                return;
            }
            else{
                switch (opt.decorate.decorateStatus) {

                    case 0: // 未申请装修评估
                        return btntmp({
                            isDisabled: false,
                            paramId: opt.houseId,
                            functionName: "decorateDialog",
                            buttonText: "申请装修评估"
                        });
                        break;

                    // case 1: // 装修评估申请中，信息出现在审核后台
                    //     return btntmp({
                    //         isDisabled: true,
                    //         buttonText: "装修评估申请中"
                    //     });
                    //     break;
                    case 2: // 申请通过，等待安装锁电，出现安装锁电按钮
                        return btntmp({
                            isDisabled: false,
                            paramId: opt.houseId,
                            functionName: "lockerAndElec",
                            buttonText: "安装锁电"
                        });
                        break;
                    // case 3: // 锁电安装中，锁电安装完成按钮出现在审核后台
                    //     return btntmp({
                    //         isDisabled: false,
                    //         buttonText: "锁电安装中"
                    //     });
                    //     break;
                    case 4: // 锁电安装完成，可生成二维码
                        return "";
                        break;

                }
            }
        }

        return [
            getContractBtn(opt),
            getHouseBtn(opt),
           
            // getDecorateBtn(opt)
        ];

    }
    initDataTables();
    function initDataTables(){
        $scope.dataTableSettings = {
             "dom": "tipr",
            "sAjaxSource": "4008",
            "bAutoWidth": true,
            "aoColumns": [
                {
                    "mDataProp": "cityName",
                    "sTitle": "电表ID",
                    "sDefaultContent": "",
                    "sClass": "center"
                }, {
                    "mDataProp": "countyName",
                    "sTitle": "设备厂商",
                    "sDefaultContent": "",
                    "sClass": "center"
                }, {
                    "mDataProp": "areaName",
                    "sTitle": "小区",
                    "sDefaultContent": "",
                    "sClass": "center"
                }, {
                    "mDataProp": "address",
                    "sTitle": "楼栋",
                    "sDefaultContent": "",
                    "sClass": "center"
                }, {
                    "mDataProp": "roomCode",
                    "sTitle": "房间号",
                    "sDefaultContent": "",
                    "sClass": "center"
                }, {
                    "mDataProp": "leaseType",
                    "sTitle": "绑定用户",
                    "sDefaultContent": "",
                    "sClass": "center"
                }, {
                    "mDataProp": "houseType",
                    "sTitle": "剩余电量(度)",
                    "sDefaultContent": "",
                    "sClass": "center"
                }, {
                    "mDataProp": "houseRent",
                    "sTitle": "电表状态",
                    "sDefaultContent": "",
                    "sClass": "center"
                }, {
                    "mDataProp": "operate",
                    "sTitle": "操作",
                    "sDefaultContent": "",
                    "sClass": "center handle-td operation"
                }
            ],
            "fnRowCallback": function(nRow, aData, iDisplayIndex) {
                var btnStr = "";
                var houseBtnStr = "";
                var contractBtnStr = "";
                var decorateBtnStr = "";
                var failureStr = "";
                var failureStr2 = "";
                var buttons = getButtons(aData);

                var btnStr = buttons.join("");

                
                if (aData.contract) {
                    if (aData.contract.status == 0) {
                        if (aData.decorate.checkStatus == 0){
                            failureStr = "<div>\
                                            <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                            <div class='decorateStatus9'>装修评估申请中</div><div class='decorateStatus9-bj'></div>\
                                        </div>"
                        }else if (aData.decorate.checkStatus == 2){
                            failureStr = "<div>\
                                            <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                            <div class='decorateStatus10'>申请失败</div><div class='decorateStatus10-bj'></div>\
                                        </div>"
                        }else if (aData.decorate.checkStatus == 5) {
                                failureStr = "<div>\
                                                <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                                <div class='decorateStatus9'>补件中</div><div class='decorateStatus12-bj'></div>\
                                            </div>"
                        }else if (aData.decorate.checkStatus == null){
                            failureStr = "<div>\
                                            <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                            <div class='decorateStatus6'>未申请装修评估</div><div class='decorateStatus5-bj'></div>\
                                        </div>"
                        }else{
                            if (aData.decorate.decorateStatus == 3) {
                                failureStr = "<div>\
                                                <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                                <div class='decorateStatus8'>锁电安装中</div><div class='decorateStatus8-bj'></div>\
                                            </div>"
                            }else if (aData.decorate.decorateStatus == 4) {
                                failureStr = "<div>\
                                                <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                                <div class='decorateStatus3'>锁电安装成功</div><div class='decorateStatus11-bj'></div>\
                                            </div>"
                            }else{
                                failureStr = "<div>\
                                        <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                        <div class='decorateStatus2'>申请成功</div><div class='decorateStatus6-bj'></div>\
                                    </div>"
                            }
                        }
                    }else if(aData.contract.status == 1) {
                        if (aData.decorate.checkStatus == 0){
                            failureStr = "<div>\
                                            <div class='decorateStatus7'>待租中</div><div class='decorateStatus7-bj'></div>\
                                            <div class='decorateStatus9'>装修评估申请中</div><div class='decorateStatus9-bj'></div>\
                                        </div>"
                        }else if (aData.decorate.checkStatus == 2){
                            failureStr = "<div>\
                                            <div class='decorateStatus7'>待租中</div><div class='decorateStatus7-bj'></div>\
                                            <div class='decorateStatus10'>申请失败</div><div class='decorateStatus10-bj'></div>\
                                        </div>"
                        }else if (aData.decorate.checkStatus == 5) {
                                failureStr = "<div>\
                                                <div class='decorateStatus7'>待租中</div><div class='decorateStatus7-bj'></div>\
                                                <div class='decorateStatus9'>补件中</div><div class='decorateStatus12-bj'></div>\
                                            </div>"
                        }else if (aData.decorate.checkStatus == null){
                            failureStr = "<div>\
                                            <div class='decorateStatus7'>待租中</div><div class='decorateStatus7-bj'></div>\
                                            <div class='decorateStatus6'>未申请装修评估</div><div class='decorateStatus5-bj'></div>\
                                        </div>"
                        }else{
                            if (aData.decorate.decorateStatus == 3) {
                                failureStr = "<div>\
                                                <div class='decorateStatus7'>待租中</div><div class='decorateStatus7-bj'></div>\
                                                <div class='decorateStatus8'>锁电安装中</div><div class='decorateStatus8-bj'></div>\
                                            </div>"
                            }else if (aData.decorate.decorateStatus == 4) {
                                failureStr = "<div>\
                                                <div class='decorateStatus1'>待租中</div><div class='decorateStatus3-bj'></div>\
                                                <div class='decorateStatus3'>锁电安装成功</div><div class='decorateStatus11-bj'></div>\
                                            </div>"
                            }else{
                                failureStr = "<div>\
                                        <div class='decorateStatus7'>待租中</div><div class='decorateStatus7-bj'></div>\
                                        <div class='decorateStatus2'>申请成功</div><div class='decorateStatus6-bj'></div>\
                                    </div>"
                            }
                        }

                    }else if(aData.contract.status == 2) {

                        if(aData.payMonthlyStatus == "OrderPreOutMemberApply") {
                            if (aData.decorate.checkStatus == 0){
                                failureStr = "<div>\
                                                <div class='decorateStatus1'>退租确认中</div><div class='decorateStatus13-bj'></div>\
                                                <div class='decorateStatus9'>装修评估申请中</div><div class='decorateStatus9-bj'></div>\
                                            </div>"
                            }else if (aData.decorate.checkStatus == 2){
                                failureStr = "<div>\
                                                <div class='decorateStatus1'>退租确认中</div><div class='decorateStatus13-bj'></div>\
                                                <div class='decorateStatus10'>申请失败</div><div class='decorateStatus10-bj'></div>\
                                            </div>"
                            }else if (aData.decorate.checkStatus == 5) {
                                    failureStr = "<div>\
                                                    <div class='decorateStatus1'>退租确认中</div><div class='decorateStatus13-bj'></div>\
                                                    <div class='decorateStatus9'>补件中</div><div class='decorateStatus12-bj'></div>\
                                                </div>"
                            }else if (aData.decorate.checkStatus == null){
                                failureStr = "<div>\
                                                <div class='decorateStatus1'>退租确认中</div><div class='decorateStatus13-bj'></div>\
                                                <div class='decorateStatus6'>未申请装修评估</div><div class='decorateStatus5-bj'></div>\
                                            </div>"
                            }else{
                                if (aData.decorate.decorateStatus == 3) {
                                    failureStr = "<div>\
                                                    <div class='decorateStatus1'>退租确认中</div><div class='decorateStatus13-bj'></div>\
                                                    <div class='decorateStatus8'>锁电安装中</div><div class='decorateStatus8-bj'></div>\
                                                </div>"
                                }else if (aData.decorate.decorateStatus == 4) {
                                    failureStr = "<div>\
                                                    <div class='decorateStatus1'>退租确认中</div><div class='decorateStatus13-bj'></div>\
                                                    <div class='decorateStatus3'>锁电安装成功</div><div class='decorateStatus11-bj'></div>\
                                                </div>"
                                }else{
                                    failureStr = "<div>\
                                            <div class='decorateStatus1'>退租确认中</div><div class='decorateStatus13-bj'></div>\
                                            <div class='decorateStatus2'>申请成功</div><div class='decorateStatus6-bj'></div>\
                                        </div>"
                                }
                            }

                        }else if(aData.payMonthlyStatus == "OrderPreOutApply"){
                            if (aData.decorate.checkStatus == 0){
                                failureStr = "<div>\
                                                <div class='decorateStatus4'>即将搬出</div><div class='decorateStatus14-bj'></div>\
                                                <div class='decorateStatus9'>装修评估申请中</div><div class='decorateStatus9-bj'></div>\
                                            </div>"
                            }else if (aData.decorate.checkStatus == 2){
                                failureStr = "<div>\
                                                <div class='decorateStatus4'>即将搬出</div><div class='decorateStatus14-bj'></div>\
                                                <div class='decorateStatus10'>申请失败</div><div class='decorateStatus10-bj'></div>\
                                            </div>"
                            }else if (aData.decorate.checkStatus == 5) {
                                    failureStr = "<div>\
                                                    <div class='decorateStatus4'>即将搬出</div><div class='decorateStatus14-bj'></div>\
                                                    <div class='decorateStatus9'>补件中</div><div class='decorateStatus12-bj'></div>\
                                                </div>"
                            }else if (aData.decorate.checkStatus == null){
                                failureStr = "<div>\
                                                <div class='decorateStatus4'>即将搬出</div><div class='decorateStatus14-bj'></div>\
                                                <div class='decorateStatus6'>未申请装修评估</div><div class='decorateStatus5-bj'></div>\
                                            </div>"
                            }else{
                                if (aData.decorate.decorateStatus == 3) {
                                    failureStr = "<div>\
                                                    <div class='decorateStatus4'>即将搬出</div><div class='decorateStatus14-bj'></div>\
                                                    <div class='decorateStatus8'>锁电安装中</div><div class='decorateStatus8-bj'></div>\
                                                </div>"
                                }else if (aData.decorate.decorateStatus == 4) {
                                    failureStr = "<div>\
                                                    <div class='decorateStatus4'>即将搬出</div><div class='decorateStatus14-bj'></div>\
                                                    <div class='decorateStatus3'>锁电安装成功</div><div class='decorateStatus11-bj'></div>\
                                                </div>"
                                }else{
                                    failureStr = "<div>\
                                            <div class='decorateStatus4'>即将搬出</div><div class='decorateStatus14-bj'></div>\
                                            <div class='decorateStatus2'>申请成功</div><div class='decorateStatus6-bj'></div>\
                                        </div>"
                                }
                            }
                        }else{
                            if (aData.decorate.checkStatus == 0){
                                failureStr = "<div>\
                                                <div class='decorateStatus1'>在租中</div><div class='decorateStatus3-bj'></div>\
                                                <div class='decorateStatus9'>装修评估申请中</div><div class='decorateStatus9-bj'></div>\
                                            </div>"
                            }else if (aData.decorate.checkStatus == 2){
                                failureStr = "<div>\
                                                <div class='decorateStatus1'>在租中</div><div class='decorateStatus3-bj'></div>\
                                                <div class='decorateStatus10'>申请失败</div><div class='decorateStatus10-bj'></div>\
                                            </div>"
                            }else if (aData.decorate.checkStatus == 5) {
                                    failureStr = "<div>\
                                                    <div class='decorateStatus1'>在租中</div><div class='decorateStatus3-bj'></div>\
                                                    <div class='decorateStatus9'>补件中</div><div class='decorateStatus12-bj'></div>\
                                                </div>"
                            }else if (aData.decorate.checkStatus == null){
                                failureStr = "<div>\
                                                <div class='decorateStatus1'>在租中</div><div class='decorateStatus3-bj'></div>\
                                                <div class='decorateStatus6'>未申请装修评估</div><div class='decorateStatus5-bj'></div>\
                                            </div>"
                            }else{
                                if (aData.decorate.decorateStatus == 3) {
                                    failureStr = "<div>\
                                                    <div class='decorateStatus1'>在租中</div><div class='decorateStatus3-bj'></div>\
                                                    <div class='decorateStatus8'>锁电安装中</div><div class='decorateStatus8-bj'></div>\
                                                </div>"
                                }else if (aData.decorate.decorateStatus == 4) {
                                    failureStr = "<div>\
                                                    <div class='decorateStatus1'>在租中</div><div class='decorateStatus3-bj'></div>\
                                                    <div class='decorateStatus3'>锁电安装成功</div><div class='decorateStatus11-bj'></div>\
                                                </div>"
                                }else{
                                    failureStr = "<div>\
                                            <div class='decorateStatus1'>在租中</div><div class='decorateStatus3-bj'></div>\
                                            <div class='decorateStatus2'>申请成功</div><div class='decorateStatus6-bj'></div>\
                                        </div>"
                                }
                            }
                        }
                    }else if(aData.contract.status == 3) {
                        if (aData.decorate.checkStatus == 0){
                            failureStr = "<div>\
                                            <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                            <div class='decorateStatus9'>装修评估申请中</div><div class='decorateStatus9-bj'></div>\
                                        </div>"
                        }else if (aData.decorate.checkStatus == 2){
                            failureStr = "<div>\
                                            <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                            <div class='decorateStatus10'>申请失败</div><div class='decorateStatus10-bj'></div>\
                                        </div>"
                        }else if (aData.decorate.checkStatus == 5) {
                                failureStr = "<div>\
                                                <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                                <div class='decorateStatus9'>补件中</div><div class='decorateStatus12-bj'></div>\
                                            </div>"
                        }else if (aData.decorate.checkStatus == null){
                            failureStr = "<div>\
                                            <div class='decorateStatus4'>空置</div><div class='decorateStatus4-b10j'></div>\
                                            <div class='decorateStatus6'>未申请装修评估</div><div class='decorateStatus5-bj'></div>\
                                        </div>"
                        }else{
                            if (aData.decorate.decorateStatus == 3) {
                                failureStr = "<div>\
                                                <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                                <div class='decorateStatus8'>锁电安装中</div><div class='decorateStatus8-bj'></div>\
                                            </div>"
                            }else if (aData.decorate.decorateStatus == 4) {
                                failureStr = "<div>\
                                                <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                                <div class='decorateStatus3'>锁电安装成功</div><div class='decorateStatus11-bj'></div>\
                                            </div>"
                            }else{
                                failureStr = "<div>\
                                        <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                        <div class='decorateStatus2'>申请成功</div><div class='decorateStatus6-bj'></div>\
                                    </div>"
                            }
                        }

                    }
                } else {
                    if (aData.decorate.checkStatus == 0){
                            failureStr = "<div>\
                                            <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                            <div class='decorateStatus9'>装修评估申请中</div><div class='decorateStatus9-bj'></div>\
                                        </div>"
                        }else if (aData.decorate.checkStatus == 2){
                            failureStr = "<div>\
                                            <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                            <div class='decorateStatus10'>申请失败</div><div class='decorateStatus10-bj'></div>\
                                        </div>"
                        }else if (aData.decorate.checkStatus == 5) {
                                failureStr = "<div>\
                                                <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                                <div class='decorateStatus9'>补件中</div><div class='decorateStatus12-bj'></div>\
                                            </div>"
                        }else if (aData.decorate.checkStatus == null){
                            failureStr = "<div>\
                                            <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                            <div class='decorateStatus6'>未申请装修评估</div><div class='decorateStatus5-bj'></div>\
                                        </div>"
                        }else{
                            if (aData.decorate.decorateStatus == 3) {
                                failureStr = "<div>\
                                                <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                                <div class='decorateStatus8'>锁电安装中</div><div class='decorateStatus8-bj'></div>\
                                            </div>"
                            }else if (aData.decorate.decorateStatus == 4) {
                                failureStr = "<div>\
                                                <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                                <div class='decorateStatus3'>锁电安装成功</div><div class='decorateStatus11-bj'></div>\
                                            </div>"
                            }else{
                                failureStr = "<div>\
                                        <div class='decorateStatus4'>空置</div><div class='decorateStatus4-bj'></div>\
                                        <div class='decorateStatus2'>申请成功</div><div class='decorateStatus6-bj'></div>\
                                    </div>"
                            }
                        }
                }

                
                $(nRow).find(".handle-td").append($compile(btnStr)($scope));
                $(nRow).find(".handle-td").prev().empty().append(time(aData.createDate));
                $(nRow).find(".failure").empty().append($compile(failureStr)($scope));

              

                tmpHouseIdArr += aData.houseId + ",";
                if (iDisplayIndex >= 9) {
                    // console.log(tmpHouseIdArr);
                }
            },
            "fnDrawCallback": function(oSettings) {
                $scope.checkStatusValue = $scope.queryParams.checkStatus;
                if ("number" == typeof $scope.checkStatusValue) {
                    $scope.checkTypeArray.map(function(ele, index) {
                        if ($scope.checkStatusValue == ele.value) {
                            $scope.checkStatus.selected = ele;
                        }
                    })
                }
                $scope.decorateStatusValue = $scope.queryParams.decorateStatus;
                if ("number" == typeof $scope.decorateStatusValue) {
                    $scope.lockTypeArray.map(function(ele, index) {
                        if ($scope.decorateStatusValue == ele.value) {
                            $scope.decorateStatus.selected = ele;
                        }
                    })
                }
            },
            "fnServerParams": function(aoData) {
                if($scope.checkStatus && $scope.checkStatus.selected){
                    $scope.queryParams.checkStatus = $scope.checkStatus.selected.value
                }
                if($scope.decorateStatus && $scope.decorateStatus.selected){
                    $scope.queryParams.decorateStatus = $scope.decorateStatus.selected.value
                }
                aoData.push({
                    'name': 'queryParams',
                    'value': $scope.queryParams
                });
                return aoData;
            }
        }
    }

    $scope.operation_none_mouseleave1 = function (e) {
        var obj = $(e.target).closest('.handle-td').find('.operation-none1');
        obj.hide();
    }

    $scope.operation_none_mouseleave2 = function (e) {
        var obj = $(e.target).closest('.handle-td').find('.operation-none2');
        obj.hide();
    }

    $scope.operation_none_mouseleave3 = function (e) {
        var obj = $(e.target).closest('.handle-td').find('.operation-none3');
        obj.hide();
    }

    $scope.initFinish = function(dataTable) {
         $scope.dataTable = dataTable;
    }
    
     //监听房间号
     $scope.$watch('_roomCode', function(newValue, oldValue) {
         $scope.queryParams.roomCode = newValue;
     })
     //监听小区名称
     $scope.$watch('_areaName', function(newValue, oldValue) {
         $scope.queryParams.areaName = newValue;
     })
     //监听详细地址
     $scope.$watch('_address', function(newValue, oldValue) {
         $scope.queryParams.address = newValue;
     })

    $scope.priceMange = function() {
          ngDialog.openConfirm({
          template: 'js/module/fund/priceMange.html',
          resolve: {
            load: function() {
                return uiLoad.load(['js/module/fund/priceMange.js'])
            }
          },
          data:{
            
          },
          scope: $scope,
          width: 600,
          // height: 700
        }).then(function(data) {

        }, function(reason) {

        });
     }



    // $scope.queryUser = function(){
    //     if($scope.queryParams.checkStatus && $scope.queryParams.checkStatus.selected){
    //         var checkStatusCache = $scope.queryParams.checkStatus.selected;
    //         if($scope.queryParams.checkStatus.selected){
    //             $scope.queryParams.checkStatus = $scope.queryParams.checkStatus.selected.value
    //         }
    //         $scope.dataTable.fnClearTable();
    //         $scope.queryParams.checkStatus = {};
    //         $scope.queryParams.checkStatus.selected = {};
    //         $scope.queryParams.checkStatus.selected = checkStatusCache;
    //     }else if($scope.queryParams.decorateStatus && $scope.queryParams.decorateStatus.selected){
    //         var decorateStatusCache = $scope.queryParams.decorateStatus.selected;
    //         if($scope.queryParams.decorateStatus.selected){
    //             $scope.queryParams.decorateStatus = $scope.queryParams.decorateStatus.selected.value
    //         }
    //         $scope.dataTable.fnClearTable();
    //         $scope.queryParams.decorateStatus = {};
    //         $scope.queryParams.decorateStatus.selected = {};
    //         $scope.queryParams.decorateStatus.selected = decorateStatusCache;
    //     }else{
    //         $scope.dataTable.fnClearTable();
    //     }

    // };

    $scope.viewOrderReturnState = function(e, houseId){
        $window.localStorage.setItem('houseId',JSON.stringify({id:houseId}));
        $state.go('app.houseOwner.viewHouse',{id:houseId});
    }
    $scope.updateOrderReturnState = function(e, houseId){
        $window.localStorage.setItem('houseId',JSON.stringify({id:houseId}));
        $state.go('app.houseOwner.editHouse',{id:houseId});
    }
    
    //创建合同
    $scope.createContractDialog = function(e, houseId){
        $window.localStorage.setItem('houseId',JSON.stringify({id:houseId}));
        $state.go('app.houseOwner.createContract',{id:houseId});
    }
    //编辑合同
    $scope.editContractDialog = function(e, contractId){
        ngDialog.openConfirm({
          template: 'views/houseOwner/editContract.html',
          resolve: {
            load: function() {
              return uiLoad.load(['js/controllers/houseOwner/editContract.js'])
            }
          },
          data:{
            contractId:contractId
          },
          scope: $scope,
          width: 1000,
          // height: 700
        }).then(function(data) {
            initDataTables();
        }, function(reason) {
            initDataTables();
        });
    }
    //查看合同
    $scope.viewContractDialog = function(e, contractId){
        ngDialog.openConfirm({
          template: 'views/houseOwner/viewContract.html',
          resolve: {
            load: function() {
              return uiLoad.load(['js/controllers/houseOwner/viewContract.js'])
            }
          },
          data:{
            contractId:contractId
          },
          scope: $scope,
          width: 1000,
          // height: 700
        }).then(function(data) {
            initDataTables();
        }, function(reason) {
            initDataTables();
        });
    }

    $scope.addHouse = function () {
        $state.go('app.houseOwner.addHouse');
    }

    $scope.addModelPics = function () {
        $state.go('app.houseOwner.housePicsTemplet');
    }

});
